<?php
/**
 * Copyright 2013 Marek Kaszewski
 *
 * This file is part of the JHUB1 Online Community Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace Jhub1_Common\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use InvalidArgumentException;
use Jhub1_Common\Model\SettingsObjects\AgentRemoteConfigurationObject;
use Jhub1_Common\Model\SettingsObjects\DateTimeObject;
use Jhub1_Common\Entity\Agents;

/**
 * @ORM\Entity
 * @ORM\Table(name="jhoAgentsEAV")
 */
class AgentsEAV extends EAVBase
{

    /**
     * @ORM\ManyToOne(targetEntity="Agents")
     * @var Agents
     * @ORM\JoinColumns({
     * @ORM\JoinColumn(name="agent_id", referencedColumnName="id")
     * })
     */
    private $owner;

    public function __construct(Agents $owner)
    {
        $this->setOwner($owner);
    }

    /** @param Agents $owner
     *  @throws InvalidArgumentException
     */
    public function setOwner($owner)
    {
        if ($owner instanceof Agents) {
            $this->owner = $owner;
        } else {
            throw new InvalidArgumentException('$owner must be instance of Agents!');
        }
    }

    public function getOwner()
    {
        return $this->owner;
    }

}
